<?Lassoscript
// Last modified 11/30/09 by Eric Landmann

// FUNCTIONALITY
// Admin edit user form

// CHANGE NOTES
// 11/30/09
// First implementation

Var:'vAction' = string;
Var:'ResponsePage' = string;
Var:'ActionLabel' = string;

// Debugging
// Var:'svDebug' = 'Y';

// Determining if it is an add or edit page
If: (Response_Filepath) >> 'setup_editrecord.lasso';
	$vAction = 'Update';
	$ResponsePage = 'setup_addresponse.lasso';
	$ActionLabel = 'Update';
/If;

// Convert action_params
Include:($svLibsPath)'user_params.inc';

Var:'SQLGetMember' = ('SELECT * FROM '+($svMembersTable)+' WHERE ID = "'+($vID)+'"');
Inline: $IV_SearchMembers, -SQL=$SQLGetMember;
	Var:'vFirst_Name' = (Field:'First_Name');
	Var:'vLast_Name' = (Field:'Last_Name');
	Var:'vPost_Name1' = (Field:'Post_Name1');
	Var:'vPost_Name2' = (Field:'Post_Name2');
	Var:'vPost_Name3' = (Field:'Post_Name3');
	Var:'vPost_Name4' = (Field:'Post_Name4');
	Var:'vPost_Name5' = (Field:'Post_Name5');
	Var:'vPass' = (Field:'Pass');
	Var:'vMail' = (Field:'Mail');
	Var:'vFav_Crag' = (Field:'Fav_Crag');
	Var:'vAddress' = (Field:'Address');
	Var:'vCity' = (Field:'City');
	Var:'vState' = (Field:'State');
	Var:'vZip' = (Field:'Zip');
	Var:'vCountry' = (Field:'Country');
	Var:'vPhone' = (Field:'Phone');
	Var:'vFav_URL' = (Field:'Fav_URL');
	Var:'vSex' = (Field:'Sex');
	Var:'vYear_Born' = (Field:'Year_Born');
	Var:'vType' = (Field:'Type');
	Var:'vAbility' = (Field:'Ability');
	Var:'vAchieve' = (Field:'Achieve');
	Var:'vStatement' = (Field:'Statement');
	Var:'vEmail_Forum1' = (Field:'Email_Forum1');
	Var:'vEmail_Forum2' = (Field:'Email_Forum2');
	Var:'vEmail_Forum3' = (Field:'Email_Forum3');
	Var:'vEmail_Forum4' = (Field:'Email_Forum4');
	Var:'vEmail_Forum5' = (Field:'Email_Forum5');
	Var:'vEmail_Forum6' = (Field:'Email_Forum6');
	Var:'vEmail_Forum7' = (Field:'Email_Forum7');
	Var:'vEmail_Forum8' = (Field:'Email_Forum8');
	Var:'vEmail_Forum9' = (Field:'Email_Forum9');
	Var:'vEmail_Forum10' = (Field:'Email_Forum10');
	Var:'vEmail_Forum11' = (Field:'Email_Forum11');
	Var:'vEmail_Forum12' = (Field:'Email_Forum12');
	Var:'vAllow' = (Field:'Allow');
/Inline;		

?><div align="center">
<form action="[$ResponsePage]" method="post">      
<table border="0" cellpadding="5" width="600">
	<tr bgcolor="#FFFFFF">
		<td colspan="2"><h2>Member Profile</h2>
		<p><strong>NOTE: </strong>Fields marked with [$svInputRequired] are required.</p></td>
	</tr>
<?Lassoscript

// Standard Error Table
If: (Var:'vError') != '';
	'\t<tr>\n';
	'\t\t<td colspan="2">\n';
	LI_ShowError3: -ErrNum=$vError, -Option=$vOption;
	'\t\t</td>\n';
	'\t</tr>\n';
/If;

// Output slightly different member name and member ID info depending on if it is add or edit
// This is because we do not allow editing of Name or Member IDs
//If: $vAction == 'Edit';

?>	<tr>
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>Member Photo</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
<?Lassoscript
// Display member photo if it exists, and Delete Photo link
Var:'PhotoName' = (($svSiteFolderRoot)'/member/'(Var:'vID')'.jpg');
Var:'PhotoExists' = boolean(File_Exists:($PhotoName));
Debug;
	'\t\t\t87: PhotoName = ' $PhotoName '<br>\n';
	'\t\t\t87: PhotoExists = ' $PhotoExists '<br>\n';
/Debug;
	If: (File_Exists:($PhotoName));
		'\t\t\t<img src="'($PhotoName)'" alt="Member Photo">&nbsp;<a href="delete_memberphoto.lasso?Member='($vID)'">Delete Photo</a>\n';
	/If;
	If: (!File_Exists:($PhotoName));
		'\t\t\t\<a href="upload_memberphoto.lasso?Member='($vID)'">Upload Photo</a>\n';
	/If;
?>
        </td>
	</tr>
	<tr> 
		<td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>First Name[$svInputRequired]</strong></div>
		</td>
		<td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="First_Name" value="[Var:'vFirst_Name']" size="15">
		</td>
	</tr>
	<tr> 
		<td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>Last Name[$svInputRequired]</strong></div>
		</td>
		<td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="Last_Name" value="[Var:'vLast_Name']" size="20">
		</td>
	</tr>
	<tr> 
		<td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>Post Names</strong><br>
			All post names are public</div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="Post_Name1" value="[Var:'vPost_Name1']" size="18" maxlength="24">
				&nbsp;&nbsp;&nbsp;<font color="red">&lt;-- First Post Name</font>[$svInputRequired]<br>
			<input type="text" name="Post_Name2" value="[Var:'vPost_Name2']" size="18" maxlength="24">
				&nbsp;&nbsp;&nbsp;&lt;-- Second Post Name<br>
			<input type="text" name="Post_Name3" value="[Var:'vPost_Name3']" size="18" maxlength="24">
				&nbsp;&nbsp;&nbsp;&lt;-- Third Post Name<br>
			<input type="text" name="Post_Name4" value="[Var:'vPost_Name4']" size="18" maxlength="24">
				&nbsp;&nbsp;&nbsp;&lt;-- Fourth Post Name<br>
			<input type="text" name="Post_Name5" value="[Var:'vPost_Name5']" size="18" maxlength="24">
				&nbsp;&nbsp;&nbsp;&lt;-- Fifth Post Name
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Password[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
        <input type="text" name="Pass" value="[Var:'vPass']" size="10" maxlength="12">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>E-mail[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="Mail" value="[Var:'vMail']" size="30" maxlength="128">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Home/Favorite Crag[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="Fav_Crag" value="[Var:'vFav_Crag']" size="39" maxlength="128">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Address[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="Address" value="[Var:'vAddress']" size="39">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>City, State/Province, Zip/Postal Code[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<input type="text" name="City" value="[Var:'vCity']" size="22">
[Include:(($svSiteFolderRoot)'/includes/selectlist_stateprov.inc')]
        <input type="text" name="Zip" value="[Var:'vZip']" size="8">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Country[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
            <SELECT NAME="Country">
            <option value="USA" [If:(Var:'vCountry')=='USA'] Selected[/If]>USA</option>
			<option value="Canada" [If:(Var:'vCountry')=='Canada'] Selected[/If]>Canada</option>
			<option value="Other" [If:(Var:'vCountry')=='Other'] Selected[/If]>Other</option>
		</select>
        </td>
      </tr>      
      <tr>
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Phone[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
        <input type="text" name="Phone" value="[Var:'vPhone']" size="16">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Favorite URL[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
        <input type="text" name="Fav_URL" value="[Var:'vFav_URL']" size="39">
        </td>
      </tr>
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Sex</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
      		<select name="Sex">
			  <option value="Male"[If:(Var:'vSex')=='Male'] Selected[/If]>Male</option>
			  <option value="Female"[If:(Var:'vSex')=='Female'] Selected[/If]>Female</option>
			</select>
        </td>
      </tr>    
       
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Year Born</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
[Include:(($svSiteFolderRoot)'/includes/selectlist_year.inc')]
		</td>
      </tr>
     <tr>  
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Type[$svInputRequired]</strong><br>
          Click all that apply</div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left">
		<input type="checkbox" name="Type" value="1"[If:(Var:'vType')=='1'] Checked[/If]>Type 1<br>
		<input type="checkbox" name="Type" value="2"[If:(Var:'vType')=='2'] Checked[/If]>Type 2<br>
		<input type="checkbox" name="Type" value="3"[If:(Var:'vType')=='3'] Checked[/If]>Type 3<br>
		<input type="checkbox" name="Type" value="4"[If:(Var:'vType')=='4'] Checked[/If]>Type 4<br>
        </td>
      </tr>  
      <tr> 
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>Ability[$svInputRequired]</strong></div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
      		<select name="Ability">
 			  <option value="1"[If:(Var:'vAbility')=='1'] selected[/If]>1</option>
 			  <option value="2"[If:(Var:'vAbility')=='2'] selected[/If]>2</option>
 			  <option value="3"[If:(Var:'vAbility')=='3'] selected[/If]>3</option>
 			  <option value="4"[If:(Var:'vAbility')=='4'] selected[/If]>4</option>
			</select>
		</td>
	</tr>    
	<tr> 
		<td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>Notable Achievements</strong></div>
		</td>
		<td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<textarea name="Achieve" cols="50" rows="4">[Var:'vAchieve']</textarea>
		</td>
	</tr>
	<tr> 
		<td width="200" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="right"><strong>Personal Statement</strong></div>
		</td>
		<td valign="top" bgcolor="[Var:'svPostContentColor']" align="left"> 
			<textarea name="Statement" cols="50" rows="3">[Var:'vStatement']</textarea>
		</td>
	</tr>
     <tr>  
        <td width="200" bgcolor="[Var:'svSearchContentColor']"> 
          <div align="right"><strong>E-mail Preferences</strong><br>
          Receive e-mail notifications of <strong>new topic</strong> posts in these Forums (you always can request e-mail notification in an individual topic, even if these are disabled):</div>
        </td>
        <td valign="top" bgcolor="[Var:'svPostContentColor']" align="left">
			<table>
				<tr>
					<td width="200">Forum 1</td>
					<td align="left">
						<input type="radio" name="Email_Forum1" value="Y"[If:(Var:'vEmail_Forum1')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum1" value="N"[If:(Var:'vEmail_Forum1')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 2</td>
					<td align="left">
						<input type="radio" name="Email_Forum2" value="Y"[If:(Var:'vEmail_Forum2')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum2" value="N"[If:(Var:'vEmail_Forum2')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 3</td>
					<td align="left">
						<input type="radio" name="Email_Forum3" value="Y"[If:(Var:'vEmail_Forum3')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum3" value="N"[If:(Var:'vEmail_Forum3')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 4</td>
					<td align="left">
						<input type="radio" name="Email_Forum4" value="Y"[If:(Var:'vEmail_Forum4')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum4" value="N"[If:(Var:'vEmail_Forum4')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 5</td>
					<td align="left">
						<input type="radio" name="Email_Forum5" value="Y"[If:(Var:'vEmail_Forum5')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum5" value="N"[If:(Var:'vEmail_Forum5')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 6</td>
					<td align="left">
						<input type="radio" name="Email_Forum6" value="Y"[If:(Var:'vEmail_Forum6')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum6" value="N"[If:(Var:'vEmail_Forum6')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 7</td>
					<td align="left">
						<input type="radio" name="Email_Forum7" value="Y"[If:(Var:'vEmail_Forum7')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum7" value="N"[If:(Var:'vEmail_Forum7')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 8</td>
					<td align="left">
						<input type="radio" name="Email_Forum8" value="Y"[If:(Var:'vEmail_Forum8')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum8" value="N"[If:(Var:'vEmail_Forum8')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 9</td>
					<td align="left">
						<input type="radio" name="Email_Forum9" value="Y"[If:(Var:'vEmail_Forum9')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum9" value="N"[If:(Var:'vEmail_Forum9')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 10</td>
					<td align="left">
						<input type="radio" name="Email_Forum10" value="Y"[If:(Var:'vEmail_Forum10')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum10" value="N"[If:(Var:'vEmail_Forum10')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 11</td>
					<td align="left">
						<input type="radio" name="Email_Forum11" value="Y"[If:(Var:'vEmail_Forum11')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum11" value="N"[If:(Var:'vEmail_Forum11')=='N'] checked[/If]>No
					</td>
				</tr>
				<tr>
					<td width="200">Forum 12</td>
					<td align="left">
						<input type="radio" name="Email_Forum12" value="Y"[If:(Var:'vEmail_Forum12')=='Y'] checked[/If]>Yes
						<input type="radio" name="Email_Forum12" value="N"[If:(Var:'vEmail_Forum12')=='N'] checked[/If]>No
					</td>
				</tr>
			</table>
        </td>
	</tr>  
	<tr>
		<td width="200" bgcolor="[Var:'svSearchContentColor']" valign="top">
			<p align="right">
				<strong>Allow</strong></font>[$svInputRequired]
			</p>
		</td>
		<td valign="top" bgcolor="[Var:'svPostContentColor']">
			<select name="Allow"> 
				<option value="" [if: (var:'vAllow') == ''] selected[/If]></option>
				<option value="Y" [if: (var:'vAllow') == 'Y'] selected[/if]>Yes</option>
				<option value="N" [if: (var:'vAllow') == 'N'] selected[/if]>No</option>
			</select> 
		</td>
	</tr>
	<tr> 
		<td colspan="2" bgcolor="[Var:'svSearchContentColor']"> 
			<div align="center">
				<input type="hidden" name="DataType" value="User">
				<input type="hidden" name="ID" value="[$vID]">
				<input type="submit" name="Action" value="[$ActionLabel]">
			</div>
		</td>
	</tr>
    </table>
</form>
</div>
